package me.feng.analyzeAS
{
	import mx.utils.StringUtil;

	/**
	 *
	 * @author feng 2016-3-31
	 */
	public class ASFunctionInfo extends ASItem
	{
		public var returnType:String;
		public var params:Vector.<ParamInfo>;
		public var block:String;
		public var headStr:String;

		public function ASFunctionInfo(result:Array)
		{
			headStr = result[0];
			init(result);
		}

		protected function init(result:Array):void
		{
			initVisit(result[1]);
			name = result[4];
			initParams(result[5]);
			initReturnType(result[7]);
		}

		protected function initReturnType(str:String):void
		{
			if (str == null)
				return;
			returnType = StringUtil.trim(str.replace(":", ""));
		}

		protected function initParams(str:String):void
		{
			params = new Vector.<ParamInfo>();
			if (str == null && StringUtil.trim(str).length == 0)
				return;

			var paramArr:Array = str.split(",");
			for (var i:int = 0; i < paramArr.length; i++)
			{
				params.push(new ParamInfo(paramArr[i].split(":")[0], paramArr[i].split(":")[1]));
			}
		}
	}
}
